<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      v-for="(item, index) in list"
      :key="index"
      :class="{ completed: item.isDone }"
    >
      <div class="view">
        <input v-model="item.isDone" class="toggle" type="checkbox" />
        <label>{{ item.name }}</label>
        <button @click="del(index)" class="destroy"></button>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  // 接收数据
  props: {
    list: {
      type: Array,
      required: true
    }
  },
  methods: {
    // 子传父 - 删除单项
    del (id) {
      this.$emit('delTask', id)
    }
  }
}
</script>
